﻿Imports System.Data.OleDb
Public Class SheetUploading
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If fup_SFile.HasFile Then
            fup_SFile.SaveAs(Server.MapPath("Sheets") & "/" & fup_SFile.FileName)
        End If
    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim sql As String = "INSERT INTO ActivitySheet (ShtFile,ShtName,ShtDescription,ShtSubject,ShtGrade,ShtCreator,ShtRegDate) VALUES (@f1,@f2,@f3,@f4,@f5,@f6,@f7)"
        Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("SheetsConnectionString").ConnectionString)
        Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)
        cmd.Parameters.AddWithValue("@f1", "Sheets/" & fup_SFile.FileName)
        cmd.Parameters.AddWithValue("@f2", tb_SName.Text)
        cmd.Parameters.AddWithValue("@f3", tb_SDesc.Text)
        cmd.Parameters.AddWithValue("@f4", dd_ShtSubjects.SelectedValue)
        cmd.Parameters.AddWithValue("@f5", dd_Shtgrade.SelectedValue)
        cmd.Parameters.AddWithValue("@f6", User.Identity.Name)
        cmd.Parameters.AddWithValue("@f2", DateTime.Now.Date())
        conn.Open()
        cmd.ExecuteNonQuery()
        conn.Close()
        cmd.Dispose()
        conn.Dispose()
        Response.Redirect("List.aspx")
    End Sub

    Protected Sub dd_ShtSubjects_SelectedIndexChanged(sender As Object, e As EventArgs) Handles dd_ShtSubjects.SelectedIndexChanged

    End Sub
End Class